import java.util.Arrays;

/**
 * Created with Intellij JDEA
 * Description:
 * User:
 * Date:2022-04-30
 * Time:23:29
 */
public class 最小差值I {
    class Solution {
        public int smallestRangeI(int[] nums, int k) {
            Arrays.sort(nums);
            int maxNum = nums[nums.length-1];
            int minNum = nums[0];
            return maxNum - minNum <= 2 * k ? 0 : maxNum - minNum - 2 * k;
        }
    }
}
